﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CTMOES;
using CTMOES.Models;

namespace CTMOES.DAL
{
    /// <summary>
    /// 选项的数据访问器
    /// </summary>
    public class OptionProvider
    {
        /// <summary>
        /// 数据库上下文
        /// </summary>
        private static readonly CTMDBEntities _db = new CTMDBEntities();

        /// <summary>
        /// 获取选项集合
        /// </summary>
        /// <param name="QueID">问题的ID</param>
        /// <returns>选项集合</returns>
        public static List<OptionModel> GetOptions(Guid QueID)
        {
            List<Options> options = _db.Options.Where(p => p.QueID == QueID).ToList();
            List<OptionModel> optionList = new List<OptionModel>();
            OptionModel tmp;
            foreach (var op in options)
            {
                tmp = new OptionModel();
                tmp.ID = op.ID;
                tmp.QueID = Guid.Parse(op.QueID.ToString());
                tmp.Description = op.Description;
                optionList.Add(tmp);
            }
            return optionList;
        }
    }
}